import os
import shutil
import json
from Utils import *
file_path = os.path.abspath(__file__)
dir_path = os.path.dirname(file_path).replace("\\file","")

desAssets = dir_path.replace("\\tools","\\assets\\resources\\tvBoxDatas\\androidBroadcast.json")

with open(desAssets, 'r') as file:
    jsonData = json.load(file)
with open(desAssets, 'r') as file:
    tex_read = file.read()

if(jsonData['isBroadcast']):
    tex_read = tex_read.replace('"isBroadcast": true','"isBroadcast": false')
else:
    tex_read = tex_read.replace('"isBroadcast": false','"isBroadcast": true')
with open(desAssets, "w") as file:
    file.write(tex_read)

with open(desAssets, 'r') as file:
    jsonData = json.load(file)

print("广播状态::")
print(jsonData['isBroadcast'])
shutil.rmtree(dir_path+'\\file\\__pycache__')